package com.xuecheng.search.controller;

import com.xuecheng.commons.model.dto.CoursePubIndexDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;


@RestController
public class SearchController {

    @Autowired
    SearchService searchService;

    //根据条件查询课程
    @PostMapping("course-search")
    public ResponseResult search (PageRequest request, @RequestBody CoursePubIndexDto dto) throws Exception {
        return searchService.search(request,dto);
    }

    //根据id查询课程发布数据:查询es
    @GetMapping("course-search/{id}")
    public ResponseResult findById (@PathVariable("id") Long id) throws IOException {
        return searchService.findById(id);
    }
}
